<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>流式布局</title>
    <style>
        .parent {
            width: 200px;
            height: 150px;
            background-color: black;
            display: flex;
            flex-flow: row wrap;
            align-content: flex-start;
        }

        .child {
            box-sizing: border-box;
            background-color: white;
            flex: 0 0 25%;
            height: 50px;
            border: 1px solid red;
        }
    </style>
</head>

<body>
    <p>每行的项目数固定，child增加会自动分行。</p>
    <div class="parent">
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
        <div class="child"></div>
    </div>
</body>

</html>